package com.hc.framework;

import android.app.Application;

import com.hc.framework.log.LogUtils;
import com.nostra13.universalimageloader.BuildConfig;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import org.litepal.LitePal;
import org.xutils.x;

/**
 * Created by hui on 2016/10/10.
 */
public class BaseUtilApplication extends Application{
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        initImageLoader();

        x.Ext.init(this);
        // isDebuge 代表当前是调试模式  true再调试的时候配置的 false上线需要配置的
        LogUtils.initParam(true);

        // 这是初始化数据库
        LitePal.initialize(this);
        //LitePalApplication.initialize(this);
    }

    private static BaseUtilApplication instance;


    private void initImageLoader() {
        ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(
                instance);
        config.memoryCacheExtraOptions(480, 800);
        config.diskCacheExtraOptions(480, 800, null);
        config.diskCacheSize(100 * 1024 * 1024); // 100 MiB
        if (BuildConfig.DEBUG) {
            config.writeDebugLogs(); // Remove for release app
        }
        ImageLoader.getInstance().init(config.build());
    }

    //    public UserInfo getUserInfo() {
//        return userInfo;
//    }
//
//    public void setUserInfo(UserInfo userInfo) {
//        this.userInfo = userInfo;
//    }
    public static BaseUtilApplication getInstance() {
        return instance;
    }
}
